<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.menu.MenuUtil" %>
<%@page import="com.infomanage.util.Consts"%>
<%@page import="com.infomanage.po.User"%>
<%@page import="com.menu.*" %>
<%@page import="com.base.tree.*" %>
<%  
	User user = (User)session.getAttribute(Consts.LOGINED_USER);
%>
<%
	String itemIndex = request.getParameter("itemIndex");
	if(itemIndex == null) {
		itemIndex = "-1";
	}
	
	String type = request.getParameter("type");
	if(type == null) type = "0";// 类别菜单
	
	String title = MenuUtil.getMenuTitle(itemIndex);
	
	int level = MenuUtil.getCurrentLevel(itemIndex);
%>
<script type="text/javascript" src="js/jquery.1.3.2.min.js"></script>
<script type="text/javascript" src="js/tree.js"></script>
<script type="text/javascript" src="js/menu_h.js"></script>
<link rel="stylesheet" type="text/css" href="css/menu.css" />

<table width="180px" height="100%" cellpadding="0" cellspacing="0" border="0" 
	style="table-layout: fixed;">
	<tr>
		<td class="menu_left_top">
			<span id="menu_lbl"><%=title%></span>
			<img src="img/menu/submenu_left_top_icon.png">
		</td>
	</tr>
	<tr>
		<td>
			<div id="menu_left" class="menu_left">
				<%
				    if(type == null || "0".equals(type)){// 列表菜单
						out.print(MenuUtil.buildSubMenu(user, itemIndex));
						out.flush();
				    }
				%>
			</div>
		</td>
	</tr>
</table>

<script type="text/javascript">
// 默认选中第一个左侧菜单
$(function(){
	var type = '<%=type%>';
	var menuDiv = document.getElementById("menu_left");
	if(type == '0') {
		menuDiv.style.paddingTop = '0px';
		var objs = $("#menu_left a[order='0']");
		
		if(objs) {
			objs.css("color", "#f87d19");
			objs.css("font-weight","bold");
			for(var i = 0; i < objs.size(); i++) {
				if(objs.get(i).hasChild == "false") {
					parent.main.location.href = objs.get(i).src;
					selectedLevel = objs.get(i).level;
				}
			}		
		}
	}else {
		menuDiv.style.paddingTop = '8px';
	}
});
</script>

<%
   // 树形菜单
   if("1".equals(type)) {
	   String xmlFile = request.getRealPath("/") +  "menu1.xml";
	   Tree tree = new TreeMenu("menu_left", xmlFile);
	   tree.registerEvent("clickTreeNode", TreeEventType.click);
	   String treeId = TreeManager.register(tree);
	   tree.view(out);
   }
%>

